/*
package cn.itcast.filter;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
@WebFilter(asyncSupported = true,urlPatterns = {"/pages/index.html"})
public class LoginFilter implements Filter {


    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse  response = (HttpServletResponse) servletResponse;
        //获取servletPath
        String servletPath = request.getServletPath();
        //判断是否包含url-pattern;
        if (
                request.getRequestURI().contains("/login")) {
            //放行
            filterChain.doFilter(servletRequest, servletResponse);
            return;
        }
        //获取session域中的validateCode,判断validateCode是否为空
        Object validateCode = request.getSession().getAttribute("validateCode");
        if (validateCode != null) {
            //不为空则放行
            filterChain.doFilter(servletRequest, servletResponse);
        }
        else{
            //没有登录跳转到登录页面
            response.sendRedirect("/login.html");
        }

    }


}*/
